<?php echo $this->element('menu'); ?>
<div class="codetails form">
<script type="text/javascript">
function make_uppercase(){
document.getElementById("CodetailComName").value=document.getElementById("CodetailComName").value.toUpperCase();
}
function liveUrlTitle()
        {
        	var defaultTitle = '';
			var NewText = document.getElementById("CodetailComName").value;
			
			if (defaultTitle != '')
			{
				if (NewText.substr(0, defaultTitle.length) == defaultTitle)
				{
					NewText = NewText.substr(defaultTitle.length);
				}	
			}
			
			NewText = NewText.toLowerCase();
			var separator = "-";
				
			// Foreign Character Attempt
			
			var NewTextTemp = '';
			for(var pos=0; pos<NewText.length; pos++)
			{
				var c = NewText.charCodeAt(pos);
				
				if (c >= 32 && c < 128)
				{
					NewTextTemp += NewText.charAt(pos);
				}
				else
				{
					if (c == '223') {NewTextTemp += 'ss'; continue;}
				if (c == '224') {NewTextTemp += 'a'; continue;}
				if (c == '225') {NewTextTemp += 'a'; continue;}
				if (c == '226') {NewTextTemp += 'a'; continue;}
				if (c == '229') {NewTextTemp += 'a'; continue;}
				if (c == '227') {NewTextTemp += 'ae'; continue;}
				if (c == '230') {NewTextTemp += 'ae'; continue;}
				if (c == '228') {NewTextTemp += 'ae'; continue;}
				if (c == '231') {NewTextTemp += 'c'; continue;}
				if (c == '232') {NewTextTemp += 'e'; continue;}
				if (c == '233') {NewTextTemp += 'e'; continue;}
				if (c == '234') {NewTextTemp += 'e'; continue;}
				if (c == '235') {NewTextTemp += 'e'; continue;}
				if (c == '236') {NewTextTemp += 'i'; continue;}
				if (c == '237') {NewTextTemp += 'i'; continue;}
				if (c == '238') {NewTextTemp += 'i'; continue;}
				if (c == '239') {NewTextTemp += 'i'; continue;}
				if (c == '241') {NewTextTemp += 'n'; continue;}
				if (c == '242') {NewTextTemp += 'o'; continue;}
				if (c == '243') {NewTextTemp += 'o'; continue;}
				if (c == '244') {NewTextTemp += 'o'; continue;}
				if (c == '245') {NewTextTemp += 'o'; continue;}
				if (c == '246') {NewTextTemp += 'oe'; continue;}
				if (c == '249') {NewTextTemp += 'u'; continue;}
				if (c == '250') {NewTextTemp += 'u'; continue;}
				if (c == '251') {NewTextTemp += 'u'; continue;}
				if (c == '252') {NewTextTemp += 'ue'; continue;}
				if (c == '255') {NewTextTemp += 'y'; continue;}
				if (c == '257') {NewTextTemp += 'aa'; continue;}
				if (c == '269') {NewTextTemp += 'ch'; continue;}
				if (c == '275') {NewTextTemp += 'ee'; continue;}
				if (c == '291') {NewTextTemp += 'gj'; continue;}
				if (c == '299') {NewTextTemp += 'ii'; continue;}
				if (c == '311') {NewTextTemp += 'kj'; continue;}
				if (c == '316') {NewTextTemp += 'lj'; continue;}
				if (c == '326') {NewTextTemp += 'nj'; continue;}
				if (c == '353') {NewTextTemp += 'sh'; continue;}
				if (c == '363') {NewTextTemp += 'uu'; continue;}
				if (c == '382') {NewTextTemp += 'zh'; continue;}
				if (c == '256') {NewTextTemp += 'aa'; continue;}
				if (c == '268') {NewTextTemp += 'ch'; continue;}
				if (c == '274') {NewTextTemp += 'ee'; continue;}
				if (c == '290') {NewTextTemp += 'gj'; continue;}
				if (c == '298') {NewTextTemp += 'ii'; continue;}
				if (c == '310') {NewTextTemp += 'kj'; continue;}
				if (c == '315') {NewTextTemp += 'lj'; continue;}
				if (c == '325') {NewTextTemp += 'nj'; continue;}
				if (c == '352') {NewTextTemp += 'sh'; continue;}
				if (c == '362') {NewTextTemp += 'uu'; continue;}
				if (c == '381') {NewTextTemp += 'zh'; continue;}
				
				}
			}
    		
			var multiReg = new RegExp(separator + '{2,}', 'g');
			
			NewText = NewTextTemp;
			
			NewText = NewText.replace('/<(.*?)>/g', '');
			NewText = NewText.replace(/\s+/g, separator);
			NewText = NewText.replace(/\//g, separator);
			NewText = NewText.replace(/[^a-z0-9\-\._]/g,'');
			NewText = NewText.replace(/\+/g, separator);
			NewText = NewText.replace(multiReg, separator);
			NewText = NewText.replace(/-$/g,'');
			NewText = NewText.replace(/_$/g,'');
			NewText = NewText.replace(/^_/g,'');
			NewText = NewText.replace(/^-/g,'');
			NewText = NewText.replace(/\.+$/g,'');
			
			if (document.getElementById("CodetailUrlTitle"))
			{
				document.getElementById("CodetailUrlTitle").value = "" + NewText;			
			}
			else
			{
				document.forms['entryform'].elements['CodetailUrlTitle'].value = "" + NewText; 
			}		
		}
</script>
<?php echo $this->Form->create('Codetail');?>
	<fieldset>
		<legend><?php __('Admin Edit Codetail'); ?></legend>
	<?php
		echo $this->Form->input('ComID');
		echo $this->Form->input('ComName',array('onkeyup'=>"make_uppercase()"));
		echo $this->Form->input('url_title');
		echo $this->Form->input('Code');
		echo $this->Form->input('Listed',array('minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY'));
		echo $this->Form->input('GICS');
		echo $this->Form->input('Website');
		echo $this->Form->input('CoAddr');
		echo $this->Form->input('CoTel');
		echo $this->Form->input('CoFax');
		echo $this->Form->input('Regry');
		echo $this->Form->input('CoSec');
		echo $this->Form->input('Activit');
		echo $this->Form->input('Exch');
		echo $this->Form->input('Cat');
		echo $this->Form->input('Type');
		echo $this->Form->input('CodeY');
		echo $this->Form->input('StartDate',array('minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)'));
		echo $this->Form->input('EndDate',array('minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)'));
		echo $this->Form->input('Announce');
		echo $this->Form->input('AnnRep');
		echo $this->Form->input('InvCtr');
		echo $this->Form->input('Email');
		echo $this->Form->input('Rating');
		echo $this->Form->input('IndustryGroup');
		echo $this->Form->input('ISIN');
		//echo $this->Form->input('TimeStamp',array('minYear' => date("Y"),'maxYear' => date("Y"),'dateFormat' => 'DMY'));
	?>
	</fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
</div>